<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>领取资料</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>


<body>
    <!--
        https://ssr.icuto.cn/cUGTUg?baseUrl=http://alb-8cq3brfhslj44xonnzer6dj9.cn-guangzhou.volcalb.com
    -->
    <div id="pc" class="content">
        <div class="content-article">
            <div class="content-article-header">
                <img src="./img/1692804818971-scaled_孙杰头像.jpg" id="content-article-header-img">
                <div class="content-article-header-right">
                    <h3>助理孙老师</h3>
                    <h5>领取课程回放及素材</h5>
                </div>
            </div>
            <div class="content-img-qrcode">
                <img class="content-article-qrcode" src="./img/1692971609019-scaled_晨晨系统码.jpg">
            </div>
            <a class="content-article-footer">长按上图二维码识别添加</a>
        </div>
        <div class="content-article-full">
        </div>
    </div>
    <div id="mobile" class="mobile">
        <div class="layout">
            <div class="img-box">
                <img class="heand_img" src="./img/icon_wx_logo.png">
            </div>
            <a class="title"></a>
            <div
                style="margin-top: 4px;flex-direction: row; margin-top: 8px; overflow:hidden; display: flex;justify-content: center; align-items: center;">
                <img class="icom_img" src="./img/icon_c5_wx.png">
                <a class="icon_text">微信</a>
            </div>
        </div>
        <div class="layout1">
            <button class="jumpBtn" type="button" onclick="onJumpWxBtn()">前往微信打开</button>
            <div style="margin-top: 24px; margin-bottom: 100px;overflow:hidden">
                <a class="text_g">无法打开时，可使用默认浏览器打开。</a>
                <a id="copyButton" data-text="Hello, World!" class="text_link">复制链接</a>
            </div>
        </div>
    </div>
    <script>
        //打开链接
        function onJumpWxBtn() {
            window.location.href = 'weixin://dl/business/?t=a6jTDER2dua';
        }

        function isMobile() {
            const userAgent = navigator.userAgent.toLowerCase();
            const mobileKeywords = ['android', 'iphone', 'ipod', 'ipad', 'windows phone'];

            for (let keyword of mobileKeywords) {
                if (userAgent.indexOf(keyword) !== -1) {
                    return true;
                }
            }

            return false;
        }

        //获取位置
        const pcElement = document.querySelector('#pc');
        const mobileElement = document.querySelector('#mobile');

        //判断
        if (isMobile()) {
            console.log('当前是手机');
            pcElement.style.display = 'none';
            onJumpWxBtn()
        } else {
            console.log('当前是电脑');
            mobileElement.style.display = 'none';
        }

        /*
        复制按钮
        */
        const copyButton = document.getElementById('copyButton');
        copyButton.addEventListener('click', function () {
            const textToCopy = copyButton.getAttribute('data-text');
            navigator.clipboard.writeText(textToCopy)
                .then(function () {
                    alert("复制成功");
                })
                .catch(function (error) {
                    console.log('复制文本失败:', error);
                });
        });

    </script>
</body>

</html>